package com.tc.mapper;

import com.tc.myDto.BusinessInformation;
import com.tc.myDto.UserApp;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

@Mapper
public interface PersonalMapper {
    //修改用户信息
    @Update("update user_app set nick_name=#{nickName},avatar_url=#{avatarUrl} where id=#{id}")
    void updateUserApp(UserApp user);
    //判断是否存在商家
    @Select("select business_id from user_app where id=#{id}")
    Boolean exist(String id);
    //创建店铺
    @Insert("insert into business_information(shop_name, username, password, img, bg_img, user_id) values(#{shopName},#{username},#{password},#{img},#{bgImg},#{userId})")
    void addShop(BusinessInformation businessInformation);
    //查询新增店铺的主键id
    @Select("select id from business_information where shop_name=#{shopName}")
    Integer getNewShopId(String shopName);
    //绑定自己店铺与自己的关系
    @Update("update user_app set business_id=#{param1} where id=#{param2}")
    void bindingUser(Integer newShopId,Integer id);
    //查询个人信息
    @Select("select * from user_app where id=#{id}")
    UserApp selectInformation(Integer id);
}
